<?php
/**
 * Created by PhpStorm.
 * User: LiuJiaJun
 * Date: 2018/12/7
 * Time: 10:33
 */

namespace api\storage\model;


use think\Model;

class SubMaterielModel extends Model
{

    protected $table = 'iwh_sub_materiel';
    protected $pk = 'uuid';

    /**
     * 根据物料号查找物料信息
     *
     * @param string $materielId
     * @return array|false|\PDOStatement|string|Model
     * @throws \think\db\exception\DataNotFoundException
     * @throws \think\db\exception\ModelNotFoundException
     * @throws \think\exception\DbException
     */
    public function findByMaterielId($materielId = ''){
        return $this->where('sub_materiel_id',$materielId)->find();
    }

    /**
     * 查询物料类型
     *
     * @param string $materielId
     * @return mixed
     */
    public function findTypeByMaterielId($materielId = ''){
        return $this->where('sub_materiel_id',$materielId)->value('shelves_type');
    }
    /**
     * 根据sub_materiel_id，更新物料表
     *
     * @param array $data
     * @param $materielId
     * @return false|int
     */
    public function updateByMaterielId($data = [],$materielId){
        return $this->isUpdate(true)->save($data,['sub_materiel_id'=>$materielId]);
    }

}